<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ShowImage extends Model
{
    protected $table='show_image';

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function getShowImageData()
    {
        $data = ShowImage::leftJoin('users','show_image.user_id','users.id')
            ->select('user_id','img_url','thumb_up','description','nickname','avatar','show_image.id as img_id')
            ->skip(0)
            ->take(4)
            ->get();

        if(empty($data)){

            $data=array();
        }

        return $data;
    }
}
